/**
 * Copyright 2009 by Christian Scheid. This file is part of the switch eclipse plugin and is licensed under the
 * GPL version 3. Please refer to the URL http://www.gnu.org/licenses/gpl-3.0.html for details.
 */
package org.digitalsoul.switchplugin;

import org.digitalsoul.switchplugin.prefs.Preferences;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

public class SwitchPlugin extends AbstractUIPlugin {

	public static final String PLUGIN_ID = "switch";
	private static SwitchPlugin plugin;
	
	@Override
    public void start(BundleContext context) throws Exception {
		super.start(context);
        if (plugin == null) {
            plugin = this;
        }
	}

	@Override
	public IPreferenceStore getPreferenceStore() {
	    return super.getPreferenceStore();
	}
	
	@Override
    public void stop(BundleContext context) throws Exception {
		plugin = null;
		super.stop(context);
	}

	public static SwitchPlugin getDefault() {
	    if (plugin == null) {
            plugin = new SwitchPlugin();
        }
        return plugin;
	}
	
    @Override
    protected void initializeDefaultPluginPreferences () {
        Preferences.setupDefaults();       
    }
}
